package com.shj.em.biz.report.dto;

import com.shj.em.biz.Constants;
import com.shj.em.util.StringUtils;
import lombok.Data;

import java.math.BigDecimal;
import java.math.RoundingMode;

@Data
public class EffortStatDTO {

    private String totalEffort = ""; // 当月总工时

    private String xiaoLvBefore = ""; // 当月员工工作效率(调整前)

    private String xiaoLvAfter = ""; // 当月员工工作效率(调整后)

    private BigDecimal totalEffortDecimal = new BigDecimal(0.00);

    private BigDecimal xiaoLvBeforeBigDecimal = new BigDecimal(0.00);
    private BigDecimal xiaoLvAfterBigDecimal = new BigDecimal(0.00);

    public String getUnitXiaoLvBefore(){ // 员工单位效率（调整前）
        if(totalEffortDecimal.compareTo(Constants.zero) == 0){
            return "0.00";
        }

        return xiaoLvBeforeBigDecimal.divide(totalEffortDecimal, 2, RoundingMode.HALF_UP).toPlainString();
    }

    public String getUnitXiaoLv(){ // 员工单位效率（调整后）
        if(totalEffortDecimal.compareTo(Constants.zero) == 0){
            return "0.00";
        }

        return xiaoLvAfterBigDecimal.divide(totalEffortDecimal, 2, RoundingMode.HALF_UP).toPlainString();
    }

    public void addTotalEffort(BigDecimal value){
        totalEffortDecimal = totalEffortDecimal.add(value);
    }

    public void addXiaoLvBefore(BigDecimal value){
        xiaoLvBeforeBigDecimal = xiaoLvBeforeBigDecimal.add(value);
    }

    public void addXiaoLvAfter(BigDecimal value){
        xiaoLvAfterBigDecimal = xiaoLvAfterBigDecimal.add(value);
    }

    public String getXiaoLvBefore(){
        if(xiaoLvBeforeBigDecimal.compareTo(Constants.zero) == 0){
            return "0.00";
        }
        return xiaoLvBeforeBigDecimal.setScale(2, RoundingMode.HALF_UP).toPlainString();
    }

    public String getXiaoLvAfter(){
        if(xiaoLvAfterBigDecimal.compareTo(Constants.zero) == 0){
            return "0.00";
        }
        return xiaoLvAfterBigDecimal.setScale(2, RoundingMode.HALF_UP).toPlainString();
    }

    public String getTotalEffort(){
        if(totalEffortDecimal.compareTo(Constants.zero) == 0){
            return "0.00";
        }
        return totalEffortDecimal.toPlainString();
    }

}
